[3주차] 이교형/[feat] 게시글 도메인 API 구현#128
Open
LGH0507 wants to merge 3 commits intoLeets-Official:이교형/mainfrom
Hidden character warning
The head ref may contain hidden characters: "\uc774\uad50\ud615/3\uc8fc\ucc28"
Open
Conversation
yeonjuncho
approved these changes
Apr 8, 2026
yeonjuncho
left a comment
There was a problem hiding this comment.
👍 코드 깔끔하게 잘 작성해주신 것 같습니다. 고생하셨습니다
Comment on lines
+93
to
+110
| // 공통 검증 로직 | ||
| // 게시글 조회 | ||
| private Post findPostOrThrow(Long postId) { | ||
| return postRepository.findById(postId) | ||
| .orElseThrow(() -> new GeneralException(ErrorCode.POST_NOT_FOUND)); | ||
| } | ||
|
|
||
| // 사용자 조회 | ||
| private User findUserOrThrow(Long userId) { | ||
| return userRepository.findById(userId) | ||
| .orElseThrow(() -> new GeneralException(ErrorCode.USER_NOT_FOUND)); | ||
| } | ||
|
|
||
| private void validatePageRange(int page) { | ||
| if (page < MIN_PAGE || page > MAX_PAGE) { | ||
| throw new GeneralException(ErrorCode.POST_INVALID); | ||
| } | ||
| } |
There was a problem hiding this comment.
저는 게시글이 존재하는지, 사용자가 존재하는지에 대한 검증 코드를 매번 메소드마다 따로 작성했었는데, 이렇게 자주 사용하는 검증 코드를 메소드로 만들어두고 쓰면 가독성도 더 좋고 확장하기도 편할 것 같습니다. 고생 많으셨습니다!
There was a problem hiding this comment.
존재하지 않는 id인 경우에 커스텀 예외로 던지고, 전역 핸들러에서 처리하는 구조도 좋은 것 같습니다. 코드 참고해서 피드백 주신 부분 보완해보겠습니다!
ruchan04
approved these changes
Apr 9, 2026
|
|
||
| private final UserService userService; | ||
|
|
||
| @Operation(summary = "유저 등록", description = "새로운 유저를 등록합니다.") |
There was a problem hiding this comment.
💬 API의 목적을 명확히 설명해 주셔서 협업하는 프론트엔드 개발자나 다른 팀원들이 이해하기 매우 좋을 것 같습니다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. 과제 요구사항 중 구현한 내용
2. 핵심 변경 사항
3. 실행 및 검증 결과
4. 완료 사항
5. 추가 사항
closed #111제출 체크리스트
{이름}/main브랜치다{이름}/{숫자}주차브랜치다